package com.example.wiki.config;

import com.example.wiki.interceptor.ActionInterceptor;
import com.example.wiki.interceptor.LogInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class springMvcConfig  implements WebMvcConfigurer {
    @Resource
    LogInterceptor logInterceptor;
    @Resource
    ActionInterceptor actionInterceptor;

    public  void  addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(logInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/test/**",
                        "/redis/**",
                        "/user/login",
                        "/category/all",
                        "/ebook/list",
                        "/doc/all/**",
                        "/doc/vote/**",
                        "/doc/find-content/**",
                        "/ebook-snapshot/**",
                        "/swagger-ui.html/**",
                        "/swagger-resources/**",
                        "/swagger-ui.html#!/**",
                        "/swagger-resources/**",
                        "/v2/**",
                        "/webjars/**",
                        "/user/giteelogin/"



                );

        registry.addInterceptor(actionInterceptor)
                .addPathPatterns(
                        "/*/save",
                        "/*/delete/**",
                        "/*/reset-password"

                );

    };

}
